package javango.polls.forms;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.google.inject.Inject;

import javango.forms.BaseForm;
import javango.forms.fields.Field;
import javango.forms.fields.FieldFactory;
import javango.forms.fields.LongChoiceField;
import javango.polls.model.Choice;
import javango.polls.model.Poll;

public class VoteForm extends BaseForm {

	Log log = LogFactory.getLog(VoteForm.class);
	
	public Field choice;
	
	public void updateChoices(Poll poll) {
		Map<String, String> choices = new HashMap<String, String>();
		for (Choice choice : poll.getChoices()) {
			log.debug("Adding choice: " + choice.toString());
			choices.put(choice.getId().toString(), choice.toString());
		}
		choice = new LongChoiceField(choices);		
	}

	@Inject
	public VoteForm(FieldFactory fieldFactory) {
		super(fieldFactory);
	}
	
	
}
